<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>展示ES6新特性</title>
		
		<script>
			//定义变量
			var a = 10;
			{  //代码块
				var a = 20;  //js重复定义变量名称，它不报错，它会覆盖以前值
				console.log(a);  //20
			}
			console.log(a);  //20
			
			let b = 100;	//let作用域支持块级别，var全局，它不支持块
			{
				let b = 200; //创建新的b，不会覆盖外部定义b。出了块b就消失
				console.log(b);  //200，就近原则
			}
			console.log(b);	//100
			
			const x = 10;		//定义常量
			x = 20;				//再次赋值，就报错误，常量不能再次赋值
			console.log(x);
		</script>
	</head>
	<body>
	</body>
</html>
